<?php
class Sosweb_View_Form_DeleteForm extends Zend_Form
{
	public function createForm()
	{
		$id = new Zend_Form_Element_Text('id');	
        $id->addFilter('StringTrim')
        		->addFilter('StripTags')
        		->setRequired(true)
        		->addValidator(Sosweb_Util_Validator_CustomValidator::getNotEmptyValidator(), true)
        		->addValidator(Sosweb_Util_Validator_CustomValidator::getStringLengthValidator(1, 10), true)
        		->setLabel('ID kuponu:')
        		->setDescription('Podaj ID kuponu (WYMAGANE)')
        		->setAttrib('class', '')
        		->setAttrib('maxlength', 10);

        $id->setDecorators(
        	array(
        		array('ViewHelper'),
        		array('Errors'),
			    array('Description', array('class' => '')),
			    array('Label', array('class' => '', 'tag' => 'p'))
        	)
        );

		$password = new Zend_Form_Element_Password('password');	
        $password->addFilter('StringTrim')
        		->addFilter('StripTags')
        		->setRequired(true)
        		->addValidator(Sosweb_Util_Validator_CustomValidator::getNotEmptyValidator(), true)
        		->addValidator(Sosweb_Util_Validator_CustomValidator::getAlnumValidator(), true)
        		->addValidator(Sosweb_Util_Validator_CustomValidator::getStringLengthValidator(6, 20), true)	
        		->setLabel('Hasło:')
        		->setDescription('Wprowadź swoje hasło (WYMAGANE)')
        		->setAttrib('class', '')
        		->setAttrib('maxlength', 20);
        		        
        $form_id = new Zend_Form_Element_Hidden('form_id');
        $form_id->setValue('1');
                
        $apply_button = new Zend_Form_Element_Submit('apply_button');
        $apply_button->setRequired(false)
        			->setIgnore(true)
        			->setLabel('Usuń');
        
        $apply_button->setDecorators(
        	array(
    			array('ViewHelper')
			)
		);
        			
        $discard_button = new Zend_Form_Element_Button('discard_button');
        $discard_button->setRequired(false)
        			->setIgnore(true)
        			->setAttrib('onclick', 'window.location.href = \'/web/Manager\';')
        			->setLabel('Anuluj');
        
        $discard_button->setDecorators(
        	array(
    			array('ViewHelper')
			)
		);

        $this->removeDecorator('Description');
        $this->addDecorator('Description', array('class' => '', 'placement' => 'prepend'));        			
		
		$this->setDescription('Wskaż kupon do edycji');
		
        $this->addElement($id)
        	->addElement($password)
        	->addElement($form_id)
        	->addElement($apply_button)
        	->addElement($discard_button)
        	->addDisplayGroup(array('apply_button', 'discard_button'), 'buttons');
        	
        $buttons_group = $this->getDisplayGroup('buttons');
        $buttons_group->setDecorators(
        	array(
    			array('FormElements'),
			    array('HtmlTag', array('tag' => 'dd', 'class' => ''))
			)
		);		
	}
}